import {reactive, ref} from "vue";
import {testPie} from "../../lib/echarts/options/pie";
import {useStore} from "vuex";


export default function () {

    let state = reactive({
        pieOption: {}
    })
    const store = useStore()
    let variable = ref(store.state.example.data)

    const getPieOption = () => {
        state.pieOption = testPie({
            series: [{
                data: [
                    {value: 1048, name: 'Search Engine'},
                    {value: 735, name: 'Direct'},
                    {value: 580, name: 'Email'}
                ]
            }]
        })
    }
    // 添加点标记
    const mapLoad = (map) => {
        let marker = new AMap.Marker({
            position: new AMap.LngLat(116.39, 39.9),   // 经纬度对象，也可以是经纬度构成的一维数组[116.39, 39.9]
            title: '北京'
        });
        map.add(marker);
    }


    getPieOption()

    return {
        state,
        variable,
        mapLoad
    }
}
